package com.cskaoyan.day31.work5.Util;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.InvocationHandler;

public class ProxyUtil {

    public static <T> T getProxy(T instance) {
        T proxy = (T) Enhancer.create(instance.getClass(),
                (InvocationHandler)  (pro, method,objects)->{
            System.out.println("调用的的类是："+ instance.getClass());
            System.out.println("调用的方法是 ：" + method);
            Object result = method.invoke(instance,objects);
            return result ;
        });
        return proxy;
    }
}
